﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Navigation;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
using System.Windows.Media;
using MS.TravelJourney.Final.Core;

namespace MS.TravelJourney.Final
{
    public partial class SettingsPage : PhoneApplicationPage
    {
        public SettingsPage()
        {
            InitializeComponent();
        }
        int index = -1;
        private void ListPicker_SelectionChanged_1(object sender, SelectionChangedEventArgs e)
        {
            var listPicker = sender as ListPicker;
            if (index > 0)
            {
                var color = listPicker.SelectedItem as string;
                var util = new Util();
                util.ModifyBackgroundStyle(color);
                util.SaveDataSettings(color);
            }

            index++;

        }
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            var color = new MS.TravelJourney.Final.Core.Util().LoadDataSettings();
            for (int i = 0; i < ListPickerColor.Items.Count; i++)
            {
                if (ListPickerColor.Items[i].ToString() == color)
                    ListPickerColor.SelectedIndex = i;
            }
        }
    }
}